package com.beauty.dressing.module.mine.activity;

import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseActivity;
import com.beauty.dressing.common.bean.LeaseBean;
import com.beauty.dressing.common.bean.RefuseJudgeBean;
import com.beauty.dressing.common.utils.Constants;

public class MyLeaseCostingActivity extends BaseActivity {
    TextView tv_deposit, tv_rent, tv_daily_price, tv_duration, tv_refund_amount, tv_next, tv_instructions;
    RefuseJudgeBean bean;
    LeaseBean leaseBean;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_my_lease_costing);
    }

    @Override
    public void findView() {
        TextView title_txt = findViewById(R.id.title_txt);
        title_txt.setText("费用计算");
        findViewById(R.id.left_img_btn).setOnClickListener(this);
        tv_deposit = findViewById(R.id.tv_deposit);
        tv_rent = findViewById(R.id.tv_rent);
        tv_daily_price = findViewById(R.id.tv_daily_price);
        tv_duration = findViewById(R.id.tv_duration);
        tv_refund_amount = findViewById(R.id.tv_refund_amount);
        tv_next = findViewById(R.id.tv_next);
        tv_instructions = findViewById(R.id.tv_instructions);
        tv_next.setOnClickListener(this);
    }

    @Override
    public void initData() {
        if (getIntent().getSerializableExtra(Constants.REFUSEJUDGEBEAN) != null) {
            bean = (RefuseJudgeBean) getIntent().getSerializableExtra(Constants.REFUSEJUDGEBEAN);
            tv_deposit.setText(bean.getDeposit() + "元");
            tv_daily_price.setText(bean.getPrice());
            tv_rent.setText(String.valueOf(bean.getCost_money() + "元"));
            tv_duration.setText(String.valueOf(bean.getUsedays() + "天"));
            tv_refund_amount.setText(String.valueOf(bean.getReturn_money() + "元"));
        }
        if (getIntent().getIntExtra(Constants.TYPE, -1) == 2) {
            tv_instructions.setText("恭喜你，该设备目前属于你了！");
            tv_next.setText("好的明白了");
        }
        if (getIntent().getSerializableExtra(Constants.ACTIVITYDATA) != null) {
            leaseBean = (LeaseBean) getIntent().getSerializableExtra(Constants.ACTIVITYDATA);
        }

    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_next:
                if (getIntent().getIntExtra(Constants.TYPE, -1) == 2) {
                    startActivity(new Intent(context, HistoricalLeaseActivity.class).putExtra(Constants.ACTIVITYDATA, leaseBean));
                } else {
                    startActivity(new Intent(context, LogisticsActivity.class).putExtra(Constants.ACTIVITYDATA, leaseBean).putExtra(Constants.REFUSEJUDGEBEAN, bean));
                }
                break;
            case R.id.left_img_btn:
                this.finish();
                break;
        }
    }
}
